package com.yanqu.road.server.cmd.wingroom.chakra;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.WingRoomChakraProto.WingRoomChakraProto;
import com.yanqu.road.pb.player.PlayerProto;
import com.yanqu.road.pb.wingroom.WingRoomProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;

/**
 * @author ：zfr
 * @date ：2022/2/23 11:34
 */
@Cmd(code = CrossProtocol.C_CROSS_WING_ROOM_CHAKRA_VISIT, desc = "厢房命盘-拜访区服请求跨服")
public class WingRoomChakraVisitCrossCmd extends CrossCommand {
    private long beVisitServerId;
    private long beVisitUserId;
    private PlayerProto.PlayerBaseTempMsg playerBaseTempMsg;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        WingRoomChakraProto.WingRoomChakraCrossVisitReqMsg msg = WingRoomChakraProto.WingRoomChakraCrossVisitReqMsg.parseFrom(packet.getBytes());
        beVisitServerId = msg.getBeVisitServerId();
        beVisitUserId = msg.getBeVisitUserId();
        playerBaseTempMsg = msg.getPlayerBaseData();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        WingRoomChakraProto.WingRoomChakraVisitFromCrossReqMsg.Builder reqMsg = WingRoomChakraProto.WingRoomChakraVisitFromCrossReqMsg.newBuilder();
        reqMsg.setVisitServerId(serverId);
        reqMsg.setVisitUserId(packet.getPlayerId());
        reqMsg.setVisitPlayerBaseData(playerBaseTempMsg);
        reqMsg.setBeVisitUserId(beVisitUserId);
        YanQuMessage message = YanQuMessageUtils.buildMessage(GameProtocol.S_CHAKRA_VISIT_FROM_CROSS, reqMsg);
        MessageHelper.sendPacket(beVisitServerId, 0, message);
    }

    @Override
    public void sendData() {

    }
}
